﻿using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;

namespace ElectronicWMSA.Warehouse
{
    public partial class List_PickingNOFrm : Form
    {
        private string strWhere = "";
        public string PickingNO = "";
        public List_PickingNOFrm()
        {
            InitializeComponent();
            this.page1.PageCurrent = 1;
            this.page1.PageSize = 10000;
            this.page1.Bind();
        }

       
        private int DBindData()
        {
            ElectronicWMSA.Comm.Forms.MsControls.PageData pageData = new ElectronicWMSA.Comm.Forms.MsControls.PageData();
            pageData.TableName = "PD_PickingList";
            pageData.PrimaryKey = "NID";
            pageData.OrderStr = "NID";
            pageData.PageIndex = this.page1.PageCurrent;
            pageData.PageSize = this.page1.PageSize;
            pageData.QueryCondition = strWhere;
            pageData.QueryFieldName = "*";

            this.page1.bindingSource.DataSource = pageData.QueryDataTable().Tables[0];
            this.page1.bindingNavigator.BindingSource = page1.bindingSource;
            this.dataGridViewUserList.AutoGenerateColumns = false;
            this.dataGridViewUserList.DataSource = this.page1.bindingSource;
            this.dataGridViewUserList.ClearSelection();
            this.dataGridViewUserList.CurrentCell = null;
            return pageData.TotalCount;
        }
        private int pageControlU_EventPaging(ElectronicWMSA.Comm.Forms.MsControls.EventPagingArg e)
        {
            return DBindData();
        }
        private void dataGridViewUserList_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            SolidBrush b = new SolidBrush(dataGridViewUserList.RowHeadersDefaultCellStyle.ForeColor);
            e.Graphics.DrawString((e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture), dataGridViewUserList.DefaultCellStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4);
        }

        private void btnUserSearch_Click(object sender, EventArgs e)
        {
            this.strWhere = "";
            string statTime = dtpTimeStart.Value.ToString("yyyy/MM/dd " + " 00:00:00");
            string EndTime = dtpTimeEnd.Value.ToString("yyyy/MM/dd HH:mm:ss");
            this.strWhere += " CreatTime BETWEEN '" + statTime + "'  AND '" + EndTime + "'";
            this.page1.Bind();
        }
        private void dataGridViewUserList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (this.dataGridViewUserList.Rows.Count > 0 && e.ColumnIndex > -1)
            {
                this.dataGridViewUserList.Rows[e.RowIndex].Selected = true;
                PickingNO = this.dataGridViewUserList.Rows[e.RowIndex].Cells["PickNO"].Value.ToString();
                this.Close();
            }
        }
    }
}
